package com.server.dao;

import com.server.pojo.MobileApp;
import com.server.pojo.MobileAppUnit;
import com.server.pojo.Unit;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;

public interface MobileAppUnitDao extends JpaRepository<MobileAppUnit,Integer> {
    MobileAppUnit findByMobileAppAndUnit(MobileApp mobileApp, Unit unit);

    @Query("SELECT mu.unit FROM MobileAppUnit mu where mu.mobileApp = :mobileApp")
    List<Unit> getUnits(@Param("mobileApp")MobileApp mobileApp);

    @Query("SELECT mu.mobileApp FROM MobileAppUnit mu where mu.unit = :unit")
    List<MobileApp> getMobileApps(@Param("unit")Unit unit);


}
